package com.linkage.jz.bankruptcy.bean.Vote;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import static com.linkage.jz.bankruptcy.adapter.Vote.ExpandableRecyclerAdapter.TYPE_PERSON;

/**
 * 表决人明细 对象
 */
public class ProVoteVotersDetail implements Serializable {


    private boolean checked;
    // TODO 联调时重写，字段需与接口一致
    private String id;//参会表决人记录id
    private String creditorName;
    private String avatar;
    private String bankruptcyProjectId;
    private String voteId;
    private String creditorId;
    private double confirmedMoney;
    private double voteMoney;
    private String groupId;
    private boolean meeting;
    private long meetingTime;
    private boolean vote;
    private long voteTime;
    private int voteOpinion;
    private String supplementOpinion;
    private String meetingNumber;
    private String sysUserId;
    private int onlineStatus;

    public boolean isDeclareAsVote() {
        return declareAsVote;
    }

    public void setDeclareAsVote(boolean declareAsVote) {
        this.declareAsVote = declareAsVote;
    }

    public boolean declareAsVote = false;

    private boolean canModify;//开启修改 0开启修改 1关闭修改

    public static ProVoteVotersDetail parseJson(JSONObject jsonObj) {
        // TODO 联调时重写，解析代码
        ProVoteVotersDetail proVoteVoters = new ProVoteVotersDetail();
        return proVoteVoters;
    }

    public static List<ProVoteVotersDetail> parseJson(JSONArray jsonArray) {
        List<ProVoteVotersDetail> list = new ArrayList<ProVoteVotersDetail>();
        if (jsonArray != null && jsonArray.length() > 0) {
            for (int i = 0; i < jsonArray.length(); i++) {
                ProVoteVotersDetail item = parseJson(jsonArray.optJSONObject(i));
                if (item != null)
                    list.add(item);
            }
        }
        return list;
    }

    /*public static List<ProVoteVotersDetail> parseJson(int page) {
        List<ProVoteVotersDetail> list = new ArrayList<ProVoteVotersDetail>();
        for(int i=1;i<=3;i++) {
            ProVoteVotersDetail proVoteVoters = new ProVoteVotersDetail();
            proVoteVoters.setId((page-1)*10 + i);
            proVoteVoters.setName("徐晓燕" + proVoteVoters.getId());
            proVoteVoters.setSureMoney(proVoteVoters.getId()*100 + "");
            proVoteVoters.setVoteMoney("7890,000.00");
            list.add(proVoteVoters);
        }
        return list;
    }

    public static List<ProVoteVotersDetail> parseJson(int group, int page) {
        List<ProVoteVotersDetail> list = new ArrayList<ProVoteVotersDetail>();
        for(int i=1;i<=2;i++) {
            ProVoteVotersDetail proVoteVoters = new ProVoteVotersDetail(1);
            proVoteVoters.setId((group-1)*10 + i);
            proVoteVoters.setName("徐晓燕" + proVoteVoters.getId());
            proVoteVoters.setSureMoney(proVoteVoters.getId()*100 + "");
            proVoteVoters.setVoteMoney("7890,000.00");
            list.add(proVoteVoters);
            list.addAll(parseJson(page));
        }
        return list;
    }*/

    public static List<ProVoteVotersDetail> parse(JsonArray arr) {
        List<ProVoteVotersDetail> list = new ArrayList<>();
        for (int i = 0; i < arr.size(); i++) {
            list.add(parse(arr.get(i).getAsJsonObject()));
        }
        return list;
    }

    public static List<ProVoteVotersDetail> parse(JsonArray arr, String groupId) {
        List<ProVoteVotersDetail> list = new ArrayList<>();
        for (int i = 0; i < arr.size(); i++) {
            ProVoteVotersDetail detail = parse(arr.get(i).getAsJsonObject());
            detail.setGroupId(groupId);
            list.add(detail);
        }
        return list;
    }

    public static ProVoteVotersDetail parse(JsonObject obj) {
        ProVoteVotersDetail bean = new Gson().fromJson(obj, ProVoteVotersDetail.class);
        return bean;
    }

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCreditorName() {
        return creditorName;
    }

    public void setCreditorName(String creditorName) {
        this.creditorName = creditorName;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getBankruptcyProjectId() {
        return bankruptcyProjectId;
    }

    public void setBankruptcyProjectId(String bankruptcyProjectId) {
        this.bankruptcyProjectId = bankruptcyProjectId;
    }

    public String getVoteId() {
        return voteId;
    }

    public void setVoteId(String voteId) {
        this.voteId = voteId;
    }

    public String getCreditorId() {
        return creditorId;
    }

    public void setCreditorId(String creditorId) {
        this.creditorId = creditorId;
    }

    public double getConfirmedMoney() {
        return confirmedMoney;
    }

    public void setConfirmedMoney(double confirmedMoney) {
        this.confirmedMoney = confirmedMoney;
    }

    public double getVoteMoney() {
        return voteMoney;
    }

    public void setVoteMoney(double voteMoney) {
        this.voteMoney = voteMoney;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public boolean isMeeting() {
        return meeting;
    }

    public void setMeeting(boolean meeting) {
        this.meeting = meeting;
    }

    public long getMeetingTime() {
        return meetingTime;
    }

    public void setMeetingTime(long meetingTime) {
        this.meetingTime = meetingTime;
    }

    public boolean isVote() {
        return vote;
    }

    public void setVote(boolean vote) {
        this.vote = vote;
    }

    public long getVoteTime() {
        return voteTime;
    }

    public void setVoteTime(long voteTime) {
        this.voteTime = voteTime;
    }

    public int getVoteOpinion() {
        return voteOpinion;
    }

    public void setVoteOpinion(int voteOpinion) {
        this.voteOpinion = voteOpinion;
    }

    public String getSupplementOpinion() {
        return supplementOpinion;
    }

    public void setSupplementOpinion(String supplementOpinion) {
        this.supplementOpinion = supplementOpinion;
    }

    public String getMeetingNumber() {
        return meetingNumber;
    }

    public void setMeetingNumber(String meetingNumber) {
        this.meetingNumber = meetingNumber;
    }

    public String getSysUserId() {
        return sysUserId;
    }

    public void setSysUserId(String sysUserId) {
        this.sysUserId = sysUserId;
    }

    public int getOnlineStatus() {
        return onlineStatus;
    }

    public void setOnlineStatus(int onlineStatus) {
        this.onlineStatus = onlineStatus;
    }

    public boolean isCanModify() {
        return canModify;
    }

    public void setCanModify(boolean canModify) {
        this.canModify = canModify;
    }
}
